Skip to content

Wake device before launching Android apps - #12322

Open
jonathanpeppers wants to merge 3 commits into
mainfrom
jonathanpeppers-wake-device-on-run
Open

Wake device before launching Android apps#12322
jonathanpeppers wants to merge 3 commits into
mainfrom
jonathanpeppers-wake-device-on-run

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Summary

  • wake sleeping devices before Microsoft.Android.Run starts an activity
  • dismiss non-secure keyguards so the deployed app becomes visible
  • keep wakeup, keyguard dismissal, and activity launch in one adb shell invocation
  • add --no-wake-device, available to MSBuild callers through $(_AndroidRunExtraArgs), as an escape hatch

Fixes #11064.

Testing

  • built Xamarin.Android.sln and configured the local Android workload
  • created an app with the in-tree dotnet new android template
  • deployed and launched it with dotnet-local.cmd run on a sleeping, locked physical device
  • confirmed the device woke, dismissed the keyguard, and displayed the app
  • verified --no-wake-device omits both device-preparation commands

Wake sleeping devices and dismiss non-secure keyguards before starting deployed applications, keeping preparation and launch in one adb shell invocation.

Add --no-wake-device as an escape hatch through the existing _AndroidRunExtraArgs passthrough and cover both command modes in device integration tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 7, 2026 20:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Microsoft.Android.Run to proactively wake an Android device and dismiss a non-secure keyguard before launching an app activity, with an opt-out flag (--no-wake-device) and a device integration test validating both behaviors.

Changes:

  • Added --no-wake-device option to Microsoft.Android.Run to skip wake/keyguard dismissal.
  • Updated the activity-start adb invocation to include wake + keyguard dismissal when enabled.
  • Extended device integration coverage to assert the adb command-line behavior with and without wakeup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Microsoft.Android.Run/Program.cs Adds wake/keyguard behavior to the adb shell … am start … launch path and introduces --no-wake-device.
tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs Adds parameterized test coverage asserting wake vs. non-wake dotnet run behavior via verbose output.

Comment thread src/Microsoft.Android.Run/Program.cs
Treat wakeup and keyguard dismissal as best effort so unsupported or secure-device behavior cannot prevent am start from running or control its exit status.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM

No correctness or safety issues found. The wake/keyguard preparation is correctly best-effort while am start remains authoritative, the opt-out is wired through the existing run arguments, and both paths have device integration coverage.

Findings: 0 errors · 0 warnings · 1 suggestion

CI is green across all 44 checks (Azure DevOps build 1545007).

Generated by Android PR Reviewer for #12322 · gpt56 · 135.4 AIC · ⌖ 9.98 AIC · ⊞ 25.7K
Comment /review to run again

Comment thread tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs Outdated
Materialize the streamed log buffer once before writing diagnostics and checking launch behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run adb shell input keyevent KEYCODE_WAKEUP during deploy/run to wake sleeping devices

2 participants